<template>
    <div class="container">
        <!-- 测量单 -->

        <!-- 详情回显数据 -->
        <!-- 测量列表 -->
        <businessListCom v-if="accountingShow == 0" @goMeasurement="goMeasurement" @goAccounting="goAccounting"
            @updatedGoodsInfo="updatedGoodsInfo" />
        <!-- 测量单 -->
        <businessMesurement v-if="accountingShow == 1" :measurement="measurement" @goBack="goBack"
            @clearMeasurement="clearMeasurement" />
        <!-- 核算单 -->
        <countSumCom v-if="accountingShow == 2" :accounting="accounting" @goBack="goBack" />
    </div>
</template>
    
<script setup>
import businessListCom from './components/businessListCom'
import businessMesurement from './components/businessMesurement'
import countSumCom from './components/countSumCom'
import { listMeasurementgetInfo, costingListGetInfo } from '@/api/costSum'
// 控制显示 测量 列表 核算
let accountingShow = ref(0)
// 跳转测量携带的数据
const measurement = ref(null)
// 跳转核算携带的数据
const accounting = ref(null)

// 跳转测量
const goMeasurement = () => {
    accountingShow.value = 1
}

// 跳转核算
const goAccounting = (v) => {
    // listMeasurementgetInfoFn(v.id,true)
    // alert(v)
    accounting.value = v
    accountingShow.value = 2
}
// 核算单详情接口
// const costingListGetInfoFn = async (v) => {
//     let params = {
//         id: v
//     }
//     let { code, data } = await costingListGetInfo(params)
//     if (code == 200) {
//         accounting.value = data
//         accountingShow.value = 2
//     }
// }
// 测量详情接口
const listMeasurementgetInfoFn = async (v, flag = false) => {
    let params = {
        id: v
    }
    let { code, data } = await listMeasurementgetInfo(params)
    if (code == 200) {
        if (flag) {
            accounting.value = data
            accountingShow.value = 2
        } else {
            measurement.value = data
            accountingShow.value = 1
        }
    }
}
// 跳转测量详情
const updatedGoodsInfo = (v) => {
    // listMeasurementgetInfoFn(v.id)
    measurement.value = v
    accountingShow.value = 1
}

// 返回上一级
const goBack = () => {
    accountingShow.value = 0
}

// 清空修改数据
const clearMeasurement = () => {
    measurement.value = null
}
</script>
    
<style scoped lang="scss"></style>
